<?php
require_once '../config/common.php';
require_once '../config/config.php';
//$user=checksession();
$type = (int) $_REQUEST["type"];
$id = (int) $_REQUEST["id"];
//$src = $_REQUEST['img'];
$conn = new mysqli(HOST, USER, PASSWORD, DATABASE);
if ($conn->connect_errno) {
    throw new Exception('连接数据库失败' . $conn->connect_error);
}
$stmt = $conn->prepare("select * from media_list where id=?");
$stmt->bind_param('i', $id);
$stmt->execute();
$stmt->bind_result($id,$type,$content,$title,$time,$src);

$stmt->fetch();
?>
<!DOCTYPE html>

<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <form action="mediaoperation.php" method="post" enctype="multipart/form-data">
            <select name="type">
                <option value="0" <?php echo $type == 0 ? 'selected="selected"' : ''; ?>>视频</option>
                <option value="1" <?php echo $type == 1 ? 'selected="selected"' : ''; ?>>音乐</option>
                <option value="2" <?php echo $type == 2 ? 'selected="selected"' : ''; ?>>照片</option>
                <option value="3" <?php echo $type == 3 ? 'selected="selected"' : ''; ?>>资讯</option>
            </select>
            <br>
            <input type="text" name="title" value="<?php echo $title; ?>"/><span>文章标题</span>
            <br>
            <input type="file" name="file"/><span>选择封面图片</span><img src="<?php echo $src; ?>" alt="原图片加载失败">
            <br>
            <input type="hidden" name="type" value="<?php echo $type; ?>"/>    
            <input type="hidden" name="act" value="update"/>
            <input type="hidden" name="id" value="<?php echo $id; ?>"/>
            <script id="container" name="content" type="text/plain"><?php echo $content; ?></script>
            <input type="submit" value="发表">
            <input type="reset" value="清空">
        </form>
        <script type="text/javascript" src="../ueditor/ueditor.config.js"></script>
        <!-- 编辑器源码文件 -->
        <script type="text/javascript" src="../ueditor/ueditor.all.js"></script>
        <!-- 实例化编辑器 -->
        <script type="text/javascript">
            var ue = UE.getEditor('container');
        </script>
    </body>
</html>